package com.mxdx.edu.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;
import com.mxdx.edu.common.ApiResult;
import com.mxdx.edu.common.CommonUtils;
import com.mxdx.edu.common.DateFormatUtils;
import com.mxdx.edu.common.DateStyle;
import com.mxdx.edu.common.log.AppLogger;
import com.mxdx.edu.enums.CmsIdEnums;
import com.mxdx.edu.enums.DisplayTypeEnums;
import com.mxdx.edu.enums.ErrorEnums;
import com.mxdx.edu.enums.SalesManTypeEnums;
import com.mxdx.edu.enums.StudentTypeEnums;
import com.mxdx.edu.service.ICmsArticleService;
import com.mxdx.edu.service.ICmsCategoryService;
import com.mxdx.edu.service.IRecruitmentPositionService;
import com.mxdx.edu.service.IResumeDeliveryRecordService;
import com.mxdx.edu.util.DictUtils;
import com.mxdx.edu.util.ServletUtil;

/**
 * 处理首页请求
 *
 * @since 2018-02-11
 * @author wangyuan
 *
 */
@Controller
public class IndexController extends BaseController{

	private AppLogger logger = new AppLogger(IndexController.class);

	@Resource
	private ICmsCategoryService cmsCategoryService;

	@Resource
	private ICmsArticleService cmsArticleService;

	@Resource
	private IRecruitmentPositionService mxRecruitmentPositionService;
	
	@Resource
	private IRecruitmentPositionService recruitmentPositionService;
	
	@Resource
	private IResumeDeliveryRecordService resumeDeliveryRecordService;


	@Value("${training.certificate.url}")
	protected String certificateUrl;


	@RequestMapping("/")
	String home() {
		return "forward:/public/index";
	}
	
	@RequestMapping(value = "/public/index")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView result = new ModelAndView("h5/mxdxIndex");
		ApiResult<Map<String, Object>> apiResult = new ApiResult<>();
        Map<String, Object> param = new HashMap<>();
        int num = 0;
		List<Map<String, Object>> mxNewsList = null;
		List<Map<String, Object>> noticeList = null;
		List<Map<String, Object>> enrollmentList = null;
		List<Map<String, Object>> developmentList = null;
		List<Map<String, Object>> studentUnionList = null;
		List<Map<String, Object>> mxzxList = null;
		Map<String, Object> headerMxNews = null;
		Map<String, Object> headerNotice = null;
		Map<String, Object> headerEnrollment = null;
		Map<String, Object> headerDevelopment = null;
        try{
			param.put("begin", num);
			param.put("endNum", 4);
			//梦想在线
			param.put("name", CmsIdEnums.MXZX.getCode());
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			param.put("parentId", 10);
			mxzxList = cmsCategoryService.findListByMap(param);
			//新闻中心
			param.put("name", CmsIdEnums.MX_NEWS.getCode());
			param.put("displayType", DisplayTypeEnums.TEXT.getCode());
			mxNewsList = cmsCategoryService.findListByMap(param);
			//新闻中心头部
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			headerMxNews = cmsCategoryService.findMapByMap(param);

			//通知公告
			param.put("name", CmsIdEnums.NOTICE.getCode());
			param.put("displayType", DisplayTypeEnums.TEXT.getCode());
			noticeList = cmsCategoryService.findListByMap(param);
			//通知公告头部
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			headerNotice = cmsCategoryService.findMapByMap(param);

			//招生信息
			param.put("name", CmsIdEnums.ENROLLMENT.getCode());
			param.put("displayType", DisplayTypeEnums.TEXT.getCode());
			enrollmentList = cmsCategoryService.findListByMap(param);
			//招生信息头部
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			headerEnrollment = cmsCategoryService.findMapByMap(param);

			//诚聘英才
			param.put("name", CmsIdEnums.DEVELOPMENT.getCode());
			param.put("displayType", DisplayTypeEnums.TEXT.getCode());
			developmentList = cmsCategoryService.findListByMap(param);
			//诚聘英才头部
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			headerDevelopment = cmsCategoryService.findMapByMap(param);

			//专家讲师
			param.put("name", CmsIdEnums.STUDENT_UNION.getCode());
			param.put("endNum", 3);
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			studentUnionList = cmsCategoryService.findListByMap(param);
		}catch (Exception e){
//			e.printStackTrace();
			super.dealException(ErrorEnums.SYSTEM_ERROR, e, apiResult, logger);
		}
		result.addObject("mxNewsList", mxNewsList);
		result.addObject("noticeList", noticeList);
		result.addObject("enrollmentList", enrollmentList);
		result.addObject("developmentList", developmentList);
		result.addObject("studentUnionList", studentUnionList);
		result.addObject("mxzxList", mxzxList);

		result.addObject("headerMxNews", headerMxNews);
		result.addObject("headerNotice", headerNotice);
		result.addObject("headerEnrollment", headerEnrollment);
		result.addObject("headerDevelopment", headerDevelopment);
		result.addObject("num", num);
		result.addObject("imageHost", imageHost);
		result.addObject("certificateUrl", certificateUrl);

        return result;
    }

	/**
	 * 获取更多公告信息
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/public/moreNews")
	@ResponseBody
	public ApiResult<String> moreNews(HttpServletRequest request){
		ApiResult<String> apiResult = new ApiResult<>();
		String sign = ServletUtil.getParameterStr(request, "sign", "");
		String num = ServletUtil.getParameterStr(request, "num", "1");
		String parentId = ServletUtil.getParameterStr(request, "parentId", "0");
		
		int currentPage = Integer.parseInt(num);
		Map<String, Object> param = new HashMap<>();
		param.put("parentId", parentId);
		param.put("begin", (currentPage-1)*4);
		param.put("endNum", 4);
		param.put("name", sign);
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
		if(sign.equals(CmsIdEnums.OUTSTANDING_STUDENTS.getDesc()) || sign.equals(CmsIdEnums.STUDENT_UNION.getDesc())){
			param.put("begin", (currentPage-1)*3);
			param.put("endNum", 3);
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		}
		//新闻中心
		List<Map<String, Object>> newsList = cmsCategoryService.findListByMap(param);
		apiResult.setResult(JSONObject.toJSONString(newsList));
		apiResult.setInfo(imageHost);
		return apiResult;
	}

	@RequestMapping(value = "/public/moreRecruitment")
	@ResponseBody
	public ApiResult<String> moreRecruitment(HttpServletRequest request){
		ApiResult<String> apiResult = new ApiResult<>();
		String num = ServletUtil.getParameterStr(request, "num", "1");
		String type = ServletUtil.getParameterStr(request, "type", "");
		int currentPage = Integer.parseInt(num);
		Map<String, Object> param = new HashMap<>();
		param.put("begin", (currentPage-1)*4);
		param.put("endNum", 4);
		if("searchJob".equals(type)){
			param.put("endNum", 6);
		}
		List<Map<String, Object>> recruitmentList = null;
		String calling = ServletUtil.getParameterStr(request, "calling", "");
        String job = ServletUtil.getParameterStr(request, "job", "");
        String cityvalue = ServletUtil.getParameterStr(request, "cityvalue", "");
        String jobPay = ServletUtil.getParameterStr(request, "jobPay", "");
        String keyword = ServletUtil.getParameterStr(request, "keyword", "");
		
        if(!"".equals(calling)) {
    		String[] callings = calling.split(",");
            for(int i = 0; i< callings.length; i++){
                int a = i + 1;
                param.put("expectedJobIndustry"+a, "%"+callings[i]+"%");
            }
    	}
        
        if(!"".equals(job)) {
        	String[] jobs = job.split(",");
            for(int i = 0; i< jobs.length; i++){
                int a = i + 1;
                param.put("job"+a, "%"+jobs[i]+"%");
            }
        }
        
        if(!"".equals(cityvalue)) {
        	String[] cityvalues = cityvalue.split(",");
            param.put("cityvalueName", "%"+cityvalues[cityvalues.length - 1]+"%");
        }
        param.put("jobPay", jobPay);
        param.put("keyword", "%"+keyword+"%");
        
        recruitmentList = recruitmentPositionService.findListByMap(param);
		dealPostWithDictValue(recruitmentList);
		apiResult.setResult(JSONObject.toJSONString(recruitmentList));
		apiResult.setInfo(imageHost);
		return apiResult;
	}
	
	private void dealPostWithDictValue(List<Map<String, Object>> dataList) {
		for (Map<String, Object> data : dataList) {
			dealPostMap(data);
		}
	}

	private void dealPostMap(Map<String, Object> data) {
		String post = CommonUtils.getStrValueFromMap(data, "post", "");
		String workPlace = CommonUtils.getStrValueFromMap(data, "workPlace", "");
		String educationalRequirements = CommonUtils.getStrValueFromMap(data, "educationalRequirements", "");
		String recruitmentNature = CommonUtils.getStrValueFromMap(data, "recruitmentNature", "");
		String workingLife = CommonUtils.getStrValueFromMap(data, "workingLife", "");
		String jobPay = CommonUtils.getStrValueFromMap(data, "jobPay", "");
		String[] postIds = post.split(",");
		StringBuffer allPostName = new StringBuffer();
		int i = 1;
		for (String postId : postIds) {
			Map<String, Object> placeMap = cacheService.getPlace(postId);
			if (placeMap != null && placeMap.containsKey("name")) {
				allPostName.append(placeMap.get("name"));
				if (i != postIds.length) {
					allPostName.append(",");
				}
			}
			i++;
		}

		data.put("allPostName", allPostName);

		data.put("educationalRequirementsName",
				DictUtils.getDictLabel(educationalRequirements, "educational_requirements", ""));
		data.put("recruitmentNatureName", DictUtils.getDictLabel(recruitmentNature, "recruitment_nature", ""));
		data.put("workingLifeName", DictUtils.getDictLabel(workingLife, "working_life", ""));
		data.put("jobPayName", DictUtils.getDictLabel(jobPay, "job_pay", ""));
		if (data.get("createDate") != null) {
			Date createDate = (Date) data.get("createDate");
			data.put("createDateValue", DateFormatUtils.DateToString(createDate, DateStyle.YYYY_MM_DD));
		}

		if (data.get("refreshDate") != null) {
			Date refreshDate = (Date) data.get("refreshDate");
			data.put("refreshDate", DateFormatUtils.DateToString(refreshDate, DateStyle.YYYY_MM_DD));
		}

		String[] placeIds = workPlace.split(",");
		StringBuffer workPlaceName = new StringBuffer();
		StringBuffer allWorkPlaceName = new StringBuffer();
		i = 1;
		for (String placeId : placeIds) {
			Map<String, Object> placeMap = cacheService.getPlace(placeId);
			if (placeMap != null && placeMap.containsKey("name")) {
				allWorkPlaceName.append(placeMap.get("name"));
				if( i == (placeIds.length -1)){
					workPlaceName.append(placeMap.get("name")).append(",");
				}else if (i == placeIds.length ) {
					workPlaceName.append(placeMap.get("name"));
				} else {
					allWorkPlaceName.append(",");
				}
			}
			i++;
		}

		data.put("workPlaceName", workPlaceName);
		data.put("allWorkPlaceName", allWorkPlaceName);
	}
	
	@RequestMapping(value = "/public/moreDelivery")
	@ResponseBody
	public ApiResult<String> moreDelivery(HttpServletRequest request){
		logger.entry("submittedResumeList", "submittedResumeList");
		ModelAndView result = new ModelAndView("/h5/sendResumeManage");
		ApiResult<Map<String, Object>> apiResult = new ApiResult<>();
		ApiResult<String> api = new ApiResult<>();
		List<Map<String, Object>> deliveryList = null;
		String num = ServletUtil.getParameterStr(request, "num", "1");
		int currentPage = Integer.parseInt(num);
		try {
			String jobBasisId = getJobBasisId(request);
			Map<String, Object> param = new HashMap<>();
			param.put("begin", (currentPage-1)*4);
			param.put("jobBasisId", jobBasisId);
			param.put("endNum", pageSize);
			param.put("limit", "limit");
			deliveryList = resumeDeliveryRecordService.findListByMap(param);
			formatDeliveryRecord(deliveryList);
			result.addObject("submittedResumeList", deliveryList);
			logger.info(apiResult);
		} catch (Exception e) {
			super.dealException(ErrorEnums.SYSTEM_ERROR, e, apiResult, logger);
		}
		api.setResult(JSONObject.toJSONString(deliveryList));
		api.setInfo(imageHost);
		getUserMapByToken(request, result);
		return api;
	}
	
	private void formatDeliveryRecord(List<Map<String, Object>> dataList) {
		for (Map<String, Object> map : dataList) {
			String sex = CommonUtils.getStrValueFromMap(map, "sex", "");
			map.put("sexName", DictUtils.getDictLabel(sex, "sex", ""));

			String education = CommonUtils.getStrValueFromMap(map, "educationalRequirements", "");
			map.put("educationName", DictUtils.getDictLabel(education, "educational_requirements", ""));

			String workingLife = CommonUtils.getStrValueFromMap(map, "workingLife", "");
			map.put("workingLifeName", DictUtils.getDictLabel(workingLife, "working_life", ""));
			if (map.get("createDate") != null) {
				Date createDate = (Date) map.get("createDate");
				map.put("createDateValue", DateFormatUtils.DateToString(createDate, DateStyle.YYYY_MM_DD));
			}
			String expectedJobIndustry = CommonUtils.getStrValueFromMap(map, "expectedJobIndustry", "");
			String[] industryIds = expectedJobIndustry.split(",");
			StringBuffer industryName = new StringBuffer();
			int i = 1;
			for (String industryId : industryIds) {
				Map<String, Object> placeMap = cacheService.getPlace(industryId);
				if (placeMap != null && placeMap.containsKey("name")) {
					industryName.append(placeMap.get("name"));
					if (i < industryIds.length) {
						industryName.append(",");
					}
				}
				i++;
			}
			map.put("expectedJobIndustryName", industryName);

			String recruitmentNature = CommonUtils.getStrValueFromMap(map, "recruitmentNature", "");
			map.put("expectedJobNatureName", DictUtils.getDictLabel(recruitmentNature, "recruitment_nature", ""));

			String workPlace = CommonUtils.getStrValueFromMap(map, "workPlace", "");
			String[] placeIds = workPlace.split(",");
			StringBuffer workPlaceName = new StringBuffer();
			i = 1;
			for (String placeId : placeIds) {
				Map<String, Object> placeMap = cacheService.getPlace(placeId);
				if (placeMap != null && placeMap.containsKey("name")) {
					workPlaceName.append(placeMap.get("name"));
					if (i < placeIds.length) {
						workPlaceName.append(",");
					}
				}
				i++;
			}
			map.put("expectedJobAreaName", workPlaceName);
			String jobPay = CommonUtils.getStrValueFromMap(map, "jobPay", "");
			map.put("jobPayName", DictUtils.getDictLabel(jobPay, "job_pay", ""));

		}
	}
	
	
	@RequestMapping(value = "/public/viewNews")
	public ModelAndView viewNews(HttpServletRequest request){
		ModelAndView result = new ModelAndView("h5/newinfo");
		String id = ServletUtil.getParameterStr(request, "articleId", "");
		String parentName = ServletUtil.getParameterStr(request, "parentName", "");
		String source = ServletUtil.getParameterStr(request, "source", "");
		Map<String, Object> param = new HashMap<>();
		Map<String, Object> map = null;
		List<Map<String, Object>> imageList = null;
		param.put("id", id);
		String indexName = "";
		boolean imageCheck = false;//是否详情页有滚动图片
		if("myClass".equals(source)){
			indexName = "我的班级";
			map = classDocumentService.findMapByMap(param);
			result.addObject("indexName", indexName);
		}else{
			map = cmsArticleService.findMapByMap(param);
			Map<String,Object> lastArticleMap = cmsArticleService.getLastArticleInfo(map.get("categoryId").toString(),(Date)map.get("createDate"));
			Map<String,Object> nextArticleMap = cmsArticleService.getNextArticleInfo(map.get("categoryId").toString(),(Date)map.get("createDate"));

			if(null!=lastArticleMap && !lastArticleMap.keySet().isEmpty()){
				result.addObject("lastId", lastArticleMap.get("id"));
				result.addObject("lastTitle", lastArticleMap.get("title"));
			}
			if(null!=nextArticleMap && !nextArticleMap.keySet().isEmpty()){
				result.addObject("nextId", nextArticleMap.get("id"));
				result.addObject("nextTitle", nextArticleMap.get("title"));
			}
		}
		if("jxjyIndex".equals(source)){
			imageCheck = true;
			param.put("parentId", 2);
			indexName = "学历学位";
			result.addObject("indexName", indexName);
		}
		if("mxdxIndex".equals(source)){
			imageCheck = true;
			indexName = "梦想在线";
			result.addObject("indexName", indexName);
			param.put("parentId", 10);
		}
		if(imageCheck){
			param.put("begin", 0);
			param.put("endNum", 4);
			param.put("name", CmsIdEnums.MXZX.getCode());
			param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
			imageList = cmsCategoryService.findListByMap(param);
		}


		if(null != map && (map.containsKey("content") || map.containsKey("classDocumentMsg"))){
			String content = CommonUtils.getStrValueFromMap(map, "content", "");
//					map.get("content").toString();
			if("".equals(content)){
				content = CommonUtils.getStrValueFromMap(map, "classDocumentMsg", "");
				map.remove("classDocumentMsg");
			}
			content = content.replaceAll("/userfiles", String.format("%s%s", cmsImageHost,"/userfiles"));
			map.put("content", content);
		}
		
		String token = sessionUtil.getTokenSession(request);
		Object object = redisUtil.get(token);
        if(null != object){
        	result.addObject("isLogin", true);
        }else{
        	result.addObject("isLogin", false);
        }
		
		result.addObject("map", map);
		result.addObject("source", source);
		result.addObject("parentName", parentName);
		result.addObject("imageHost", imageHost);
		result.addObject("imageList", imageList);
		return result;
	}

	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/public/jxjyIndex")
    public ModelAndView jxjyIndex(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView result = new ModelAndView("h5/jxjyIndex");
        String token = sessionUtil.getTokenSession(request);
        Object object = redisUtil.get(token);
        if(object != null){
			Map<String, Object> studentMap = (Map<String, Object>)object;
			String studentType = CommonUtils.getStrValueFromMap(studentMap, "studentType", "");
			//不为在校生 不为预录生
			if(!(String.valueOf(StudentTypeEnums.ENROLLED_STUDENTS.getCode()).equals(studentType) || String.valueOf(StudentTypeEnums.TOURISTS.getCode()).equals(studentType))){
				String studentId = CommonUtils.getStrValueFromMap(studentMap, "studentId", "");
				Map<String, Object> updateStudentMap = new HashMap<>();
				updateStudentMap.put("studentId", studentId);
				updateStudentMap.put("studentType", StudentTypeEnums.TOURISTS.getCode());
				studentService.updateStudentInfoByMap(updateStudentMap);
				studentMap.put("studentType", String.valueOf(StudentTypeEnums.TOURISTS.getCode()));
				redisUtil.set(token, studentMap);
			}
		}

		Map<String, Object> param = new HashMap<>();
		int num = 0;

		param.put("begin", num);
		param.put("endNum", 4);
		param.put("name", CmsIdEnums.MXZX.getCode());
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		param.put("parentId", 2);
		List<Map<String, Object>> jxjyList = cmsCategoryService.findListByMap(param);

		//学院工作
		param.put("name", CmsIdEnums.STUDENT_WORK.getCode());
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
		List<Map<String, Object>> studentWorkList = cmsCategoryService.findListByMap(param);
		//学院工作头部
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		Map<String, Object> headerStudentWork = cmsCategoryService.findMapByMap(param);
		//招生信息
		param.put("name", CmsIdEnums.ENROLLMENT.getCode());
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
		List<Map<String, Object>> enrollmentList = cmsCategoryService.findListByMap(param);
		//招生信息头部
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		Map<String, Object> headerEnrollmentList = cmsCategoryService.findMapByMap(param);
		//优秀学生
		param.put("name", CmsIdEnums.OUTSTANDING_STUDENTS.getCode());
		param.put("endNum", 3);
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		List<Map<String, Object>> outstandingStudentsList = cmsCategoryService.findListByMap(param);

		//专家讲师
		param.put("name", CmsIdEnums.STUDENT_UNION.getCode());
		param.put("endNum", 3);
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		List<Map<String, Object>> studentUnionList = cmsCategoryService.findListByMap(param);


		result.addObject("studentWorkList", studentWorkList);
		result.addObject("enrollmentList", enrollmentList);
		result.addObject("outstandingStudentsList", outstandingStudentsList);
		result.addObject("studentUnionList", studentUnionList);
		result.addObject("jxjyList", jxjyList);

		result.addObject("headerStudentWork", headerStudentWork);
		result.addObject("headerEnrollmentList", headerEnrollmentList);
		result.addObject("imageHost", imageHost);
        return result;
    }

	@RequestMapping(value = "/auth/successIndex")
	public ModelAndView successIndex(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView result = new ModelAndView("h5/successIndex");
		Map<String, Object> param = new HashMap<>();
		int num = 0;
		param.put("parentId", 2);
		param.put("begin", num);
		param.put("endNum", 4);
		//学院工作
		param.put("name", CmsIdEnums.STUDENT_WORK.getCode());
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
		List<Map<String, Object>> studentWorkList = cmsCategoryService.findListByMap(param);
		//学院工作头部
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		Map<String, Object> headerStudentWork = cmsCategoryService.findMapByMap(param);
		//招生信息
		param.put("name", CmsIdEnums.ENROLLMENT.getCode());
		param.put("displayType", DisplayTypeEnums.TEXT.getCode());
		List<Map<String, Object>> enrollmentList = cmsCategoryService.findListByMap(param);
		//招生信息头部
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		Map<String, Object> headerEnrollmentList = cmsCategoryService.findMapByMap(param);
		//优秀学生
		param.put("name", CmsIdEnums.OUTSTANDING_STUDENTS.getCode());
		param.put("endNum", 3);
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		List<Map<String, Object>> outstandingStudentsList = cmsCategoryService.findListByMap(param);

		//专家讲师
		param.put("name", CmsIdEnums.STUDENT_UNION.getCode());
		param.put("endNum", 3);
		param.put("displayType", DisplayTypeEnums.IMAGE.getCode());
		List<Map<String, Object>> studentUnionList = cmsCategoryService.findListByMap(param);


		result.addObject("studentWorkList", studentWorkList);
		result.addObject("enrollmentList", enrollmentList);
		result.addObject("outstandingStudentsList", outstandingStudentsList);
		result.addObject("studentUnionList", studentUnionList);

		result.addObject("headerStudentWork", headerStudentWork);
		result.addObject("headerEnrollmentList", headerEnrollmentList);
		result.addObject("imageHost", imageHost);
		return result;
	}
	
	@RequestMapping("/index")
	String homePc() {
		return "forward:/public/index/pc";
	}
	
	@RequestMapping(value = "/public/index/pc")
    public ModelAndView indexPc(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView result = new ModelAndView("pc/index");
        return result;
    }
	
	@RequestMapping(value = "/public/index/error")
    public ModelAndView error(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> retMap = new HashMap<>();
		String salesManType = ServletUtil.getParameterStr(request, "salesManType", "");
		String salesManTypeName = SalesManTypeEnums.getMap().get(salesManType).getDesc();
		retMap.put("message", "当前用户为:"+salesManTypeName);
        ModelAndView result = new ModelAndView("h5/error");
        result.addObject("exception", retMap);
        return result;
    }

	/**
	 * 跳转加盟合作页面
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/public/toCooperation")
	public ModelAndView toCooperation(HttpServletRequest request){
		logger.entry(ServletUtil.getClientIp(request), "toLogin");
		ModelAndView result = new ModelAndView("pc/cooperation");
		logger.info(ServletUtil.getClientIp(request));
		return result;
	}
}
